<template>
  <div class="one">
    <el-input v-model="account" placeholder="请输入账号"></el-input>

    <el-input
      placeholder="请输入密码"
      v-model="password"
      show-password
    ></el-input>

    <el-checkbox v-model="checked">记住密码</el-checkbox>
  </div>
</template>

<script>
export default {
  created() {
    var checked = localStorage.getItem("checked");
    if (checked == 0) {
      this.account = localStorage.getItem("account");
      this.password = localStorage.getItem("password");
      this.checked=true
    }else{
       this.checked=false
    }
  },
  watch: {
    checked(value) {
      console.log(value);
      if (value) {
        localStorage.setItem("account", this.account);
        localStorage.setItem("password", this.password);
        localStorage.setItem("checked", 0);
      } else {
        localStorage.removeItem("account");
        localStorage.removeItem("password");
        localStorage.setItem("checked", 1);
      }
    },
  },

  data() {
    return {
      account: "",
      password: "",
      checked: true,
    };
  },
};
</script>

<style scoped>
.one{
  width: 500px;
  height: 500px;
  border: 2px solid red;
}
</style>